<template>
  <view>
    <view class="cu-bar bg-white solid-bottom margin-top">
      <view class="action">
        <text class="cuIcon-title text-orange"></text>错题列表
      </view>
    </view>
    <view v-if="list == null">你并无记录!</view>
    <view class="cu-list menu sm-border">
      <view
        class="cu-item arrow"
        v-for="(item,index) in list"
        :key="index"
        @click="handleGo(item.id)"
      >
        <view class="content">
          <text class="cuIcon-discoverfill text-orange"></text>
          <text class="text-grey">{{item.examname}}</text>
        </view>

        <view class="action">
          <text class="text-grey text-sm" style="padding-right:10rpx;">{{item.time}}</text>
          <text class="text-pink text-sm">分数:{{item.score}}分</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import moment from "moment";
moment.locale("zh-cn");
export default {
  onLoad() {
    this.id = uni.getStorageSync("user").id;
    this.getList();
  },
  methods: {
    handleGo(id) {
      uni.navigateTo({
        url: "/pages/answer/index?id=" + id
      });
    },
    getList() {
      this.request({
        url: this.apiServer + "/record/findMyRecordByUId?uId=" +  this.id
      }).then(res => {
        for (var i = 0; i < res.data.length; i++) {
          res.data[i].time = moment(res.data[i].createTime).fromNow();
        }
        this.list = res.data;
      });
    }
  },
  data() {
    return {
      list: [],
      id:0
    };
  }
};
</script>

<style>
</style>